*YPSP ROBUSTNESS CHECK: SECULAR INVOLVEMENT
clear
cd "~/Dropbox/Life cycle paper/JOP submission/Replication files/YPSP/"
use "student data.dta"
set more off

local demo_controls ne73 south73 west73 male black colprep65 i.inc73 attend73 children73 married73 closewrents73 nam73
local background_controls i.relig65 i.church465 i.lit65 closewrents65 p_churchave65 fa_pid65 mo_pid65 p_educave65 p_incave65
local attitude_controls supportnam women marijuana econlib busing aid

foreach j of numlist 82{
foreach i in  infforgmem frtnlorgmem civicorgmem nbrorgmem sportsorgmem proforgmem contact turnout{
preserve
qui: xi: logit `i'`j' i.pid373 `i'73 `demo_controls' `background_controls' `attitude_controls', cl(psu)
margins, dydx(_Ipid373_3)
		mat B = r(table)
		gen y= .
		gen se= .
		replace y = B[1,1] 
		replace se = B[2,1] 
collapse y se, by(X)
save "/Users/michelemargolis/Desktop/temp_`i'.dta", replace
restore
}
}

clear
use "/Users/michelemargolis/Desktop/temp_proforgmem.dta"
append using "/Users/michelemargolis/Desktop/temp_civicorgmem.dta"
append using "/Users/michelemargolis/Desktop/temp_nbrorgmem.dta"
append using "/Users/michelemargolis/Desktop/temp_sportsorgmem.dta"
append using "/Users/michelemargolis/Desktop/temp_infforgmem.dta"
append using "/Users/michelemargolis/Desktop/temp_frtnlorgmem.dta"
append using "/Users/michelemargolis/Desktop/temp_contact.dta"
append using "/Users/michelemargolis/Desktop/temp_turnout.dta"
cd "~/Dropbox/Life cycle paper/"

g dv = _n

g lb=y-(1.64*se)
g ub=y+(1.64*se)

gr tw (scatter dv y, col(black) msymbol(circle)) (rcap lb ub dv, hor col(black) lpattern(dash) lwidth(medthick)) ///
 (pcarrowi -0.85 0.05 -0.85 0.25) (pcarrowi -0.85 -0.05 -0.85 -0.25),  ///
ylabel(none) xlabel(none) title() legend(off) ///
xlabel(-0.3(0.10)0.3, nogrid labsize(medium)) scheme(lean1) ///
xscale(range(-0.33, 0.35)) yscale(range(-1.25, 8.5)) ///
ytitle("") xline(0, lpattern(dot) lcol(gs6) lwidth(thick)) ///
text(5 0.25 "Informal organization", size(medium)) text(6 0.25 "Fraternal organization", size(medium)) text(3 0.24 "Neighborhood organization", size(medium)) text(4 0.25 "Sports organization", size(medium)) text(1 0.25 "Professional organization", size(medium)) text(2 0.25 "Civic organization", size(medium)) text(7 0.25 "Contact elected official", size(medium)) text(8 0.25 "Presidential turnout", size(medium)) ///
text(-0.45 -0.15 "Less participation", size(medium))  text(-0.45 0.15 "More participation", size(medium)) ///
xtitle("Republican change in secular participation relative to Democrats, 1973 to 1982", size(medium))

